home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / g_mouse.zip / USER.TXT < prev   
Text File  |  1992-09-25  |  10KB  |  246 lines

  1. *****************************************************************************
  2. *                                                                           *
  3. *                        Graphics Unit For The Mouse                        *
  4. *                                     by                                    *
  5. *                             Jean-Laurent PRADEL                           *
  6. *                                                                           *
  7. *                                 Version 1.0                               *
  8. *                                                                           *
  9. *****************************************************************************
  10.  
  11.  
  12.  
  13.                                  Introduction
  14.                                  ____________
  15.  
  16.  
  17.      When I test the TP6 for the first time, my biggest disappointment was
  18. that it was always impossible to program the mouse in graphic mode! After few
  19. weeks, I found a small book about this under TP5. Just the time for my blood
  20. to make a turn in my body and I make my first try...
  21.  
  22.      Here you will find the result of my thinking and some system handing up!
  23.  
  24.      If you don't want to read immediatly all those details, you can try my
  25. demo program which could be programmed in a better way, but it is just here
  26. to show you what I did...
  27.  
  28.  
  29.                         ───────────────o───────────────
  30.  
  31.                               Types and Constants
  32.  
  33.  
  34.      In first, there is a type which is used to create the mouse pattern:
  35.  
  36.          Type MousePattern = Record
  37.                                 InsertX : word;
  38.                                 InsertY : word;
  39.                                 Pattern : Array [0..15] of String [16];
  40.                              End;
  41.  
  42.      The mouse cursor is a small pattern of 16*16 pixels. The variables
  43. InsertX and InsertY define the INSERTION POINT in this pattern; it is the
  44. point in the pattern which define the mouse position.
  45.      The array contains the shape of the cursor. For exemple, the arrow is
  46. defined by :
  47.  
  48.       Const Arrow : MousePattern = (InsertX: 2;
  49.                                     InsertY: 1;
  50.                                     Pattern: ('  0             ',
  51.                                               ' 020            ',
  52.                                               ' 0220           ',
  53.                                               ' 02220          ',
  54.                                               ' 022220         ',
  55.                                               ' 0222220        ',
  56.                                               ' 02222220       ',
  57.                                               ' 022222220      ',
  58.                                               ' 0222222220     ',
  59.                                               ' 02222222220    ',
  60.                                               ' 0222222000     ',
  61.                                               ' 02000220       ',
  62.                                               '  0  0220       ',
  63.                                               '      0220      ',
  64.                                               '      0220      ',
  65.                                               '       00       '));
  66.  
  67.      With my method, there is in the same array the mask and the shape. For
  68. that you need 4 caracters :
  69.  
  70.      - ' ' (Space Caracter) : The background will be displayed.
  71.      - '0'                  : A black point will be displayed.
  72.      - '1'                  : A white point will be displayed.
  73.      - '2'                  : The background will be displayed in the
  74.                               complementary colour.
  75.  
  76.      I know that it isn't so easy to see the difference between a 1 and a 2
  77. in the middle of others 0, 1 and 2. But it is really easy to type on the
  78. keyboard and easier to read than a set of hexadecimal codes!...
  79.  
  80.                                   ─────o─────
  81.  
  82.      After that, I have defined 7 constants for the codes of the buttons and
  83. 4 others for predefined cursors:
  84.  
  85.  
  86.    Left, Middle, Right, LeftMiddle, MiddleRight, LeftRight, LeftMiddleRight
  87.  
  88.                  Arrow, Target, Bomb and QuestionMark.
  89.  
  90.  
  91.      KingOfMouse is a variable which is initialized by the function TestMouse.
  92.  
  93.                         ───────────────o───────────────
  94.  
  95.                                    Procedures
  96.  
  97.  
  98.  
  99. Procedure MouseState(Var dx,dy,button:word);
  100.  
  101.       This procedure brings you back the position of the mouse and the state
  102. of the button (see constants). dx and dy are the real coordinates between 0
  103. and 639. In CGA mode, the dx coordinate is gave in the range 0..639 (like in
  104. EGA or VGA mode).
  105.  
  106.                                   ─────o─────
  107.  
  108. Procedure ChangeMouse(Drawing:MousePattern);
  109.  
  110.       This procedure changes the mouse cursor with the variable Drawing. The
  111. type MousePattern was explained just before.
  112.  
  113.                                   ─────o─────
  114.  
  115. Procedure Show_Mouse;
  116.  
  117.       This procedure shows the mouse!!! You must be care, the same procedure
  118. exists in the Drivers unit of TurboVision, but it is called "ShowMouse" and
  119. not "Show_Mouse"!!!
  120.  
  121.                                   ─────o─────
  122.  
  123. Procedure Hide_Mouse;
  124.  
  125.       This procedure hides the mouse (yeah, really!)!!! And...? You must be
  126. care because blablabla... blabla... blablabla... "HideMouse" blablabla...
  127. "Hide_Mouse"!!!
  128.       Nevertheless, it is important to hide the mouse before drawing anything
  129. in the background, if you don't want to see some strange things on the screen.
  130.  
  131.                                   ─────o─────
  132.  
  133. Procedure WaitBox(x1,y1,x2,y2,button:word);
  134.  
  135.       This procedure waits (!) that the user click in the area (x1,y1),(x2,y2)
  136. with the button "button" (see constants).
  137.  
  138.                                   ─────o─────
  139.  
  140. Procedure PutMouse(x,y:word);
  141.  
  142.       This procedure moves the mouse to the point (x,y). You don't need to use
  143. Hide_Mouse before this procedure (and of course to use Show_Mouse after).
  144.  
  145.                                   ─────o─────
  146.  
  147. Procedure WaitButton (Var a,b,button:word);
  148.  
  149.       This procedure waits (!) the user clicks a button and gives you back
  150. the coordinates of the mouse at this moment and which button was used.
  151.  
  152.                                   ─────o─────
  153.  
  154. Procedure MouseLimits (x1,y1,x2,y2:word);
  155.  
  156.       This procedure defines a box (x1,y1),(x2,y2) out of which the mouse
  157. can't go.
  158.  
  159.                                   ─────o─────
  160.  
  161. Procedure UnLimitMouse;
  162.  
  163.       This procedure deletes the limits made by the procedure MouseLimits.
  164.  
  165.                                   ─────o─────
  166.  
  167. Procedure PositionPress (Var x,y,button:word);
  168.  
  169.       This procedure gives you back the position of the mouse when the button
  170. "button" has been pressed at the last time. But, in this case, "button" does
  171. not go with the constants for buttons! If "button" is even then the left-button
  172. is tested, and if "button" is odd then the right-button is tested. I don't
  173. know how to do better (for the moment).
  174.  
  175.                                   ─────o─────
  176.  
  177. Procedure PositionRelease (Var x,y,button:word);
  178.  
  179.       This procedure gives you back the position of the mouse when the button
  180. "button" has been released at the last time. The variable "button" works like
  181. in PositionPress.
  182.  
  183.                                   ─────o─────
  184.  
  185. Procedure Box (x,y,l,h,ctour,cint,ctext:word;text:String);
  186.  
  187.       This procedure has nothing to do with the mouse, but I think that it is
  188. really usefull. It draws a box, centred on (x,y), with a length of l and a
  189. height of h. The color of the border is ctour, that of the inside is cint. You
  190. can put a text in with the colour ctext.
  191.  
  192.                         ───────────────o───────────────
  193.  
  194.                                    Functions
  195.  
  196.  
  197. Function TestMouse:Boolean;
  198.  
  199.       This function is the first thing that you MUST do in your initialization
  200. procedure. This function tests the driver of the mouse.
  201.       If there is no driver, the result is False.
  202.       If there is a driver active, the result is True.
  203.       More, this function initializes the variable KindOfMouse which gives you
  204. the number of buttons on the mouse.
  205.  
  206.                                   ─────o─────
  207.  
  208. Function TestButton(x1,y1,x2,y2,button:word):boolean;
  209.  
  210.       This function becames True if the mouse is in the box (x1,y1),(x2,y2)
  211. and the button "button" is pressed. In any other case, the function is False.
  212.  
  213.                         ───────────────o───────────────
  214.  
  215.                                 That 's all !!!
  216.  
  217.  
  218.       That 's all, but not at all!!! This unit is the first thing which lives
  219. Bob (Bob is my computer) and my house (euh... my appartment). And of course,
  220. it is possible to do better (with my program and with my english!).
  221.       So, I will be very happy if you send me some echos of what happens with
  222. my unit.
  223.       I already know a problem... : When you run Windows, this program
  224. changes something in your driver. After that, your driver only recognizes 2
  225. buttons (even if you have a lovely mouse with 3 buttons), and my unit only
  226. sees a mouse with 2 buttons!!!.
  227.  
  228.       For example, I have never try my unit under Hercule Mode (and I'll be
  229. surprised if it works... There is always some problem with Hercule Mode!).
  230.       Of course, if you think to send me a letter, it would be very fine to
  231. encourage me with some money (in DM or Francs), I am a poor french chemistry
  232. studiant exile in Germany...
  233.  
  234.  
  235.       Until June 93:                     After June 93:
  236.  
  237.       Jean-Laurent PRADEL                Jean-Laurent PRADEL
  238.       Im Sohlgraben 1A                   Ch. Piegros Sud
  239.       D-3550 MARBURG/CAPPEL              Villa Le Sapin Bleu
  240.       Germany                            83170 BRIGNOLES
  241.                                          France
  242.  
  243.       E-Mail : pidou@astro.chemie.uni-marburg.de
  244.  
  245.       Thank you and a lot of fun....................Danke und viele Spaß
  246.